<include file="public@header" />
</head>
<body>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<li><a href="{:url('gift/index')}">礼物列表</a></li>
			<li><a href="{:url('gift/add')}">礼物添加</a></li>
			<li class="active"><a>下发礼物</a></li>
		</ul>
		<form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('gift/issuedpost')}">
			<div class="form-group">
				<label class="col-sm-2 control-label"><span class="form-required">*</span>明星</label>
				<div class="col-md-6 col-sm-10">
					<input class="form-control" type="text" required value="" placeholder="请选择要下发的明星" onclick="doSelectCategory();" id="js-categories-name-input" readonly/>
					<input class="form-control" type="hidden" value="" name="g_udid" id="js-categories-id-input"/>
                    <input class="form-control" type="hidden" value="{$glid}" name="g_glid"/>
				</div>
			</div>
			<div class="form-group">
				<label for="input-g_amount" class="col-sm-2 control-label"><span class="form-required">*</span>下发数量</label>
				<div class="col-md-6 col-sm-10">
					<input type="number" class="form-control" id="input-g_amount" name="g_amount" max="1000" min="1">
				</div>
			</div>
            <div class="form-group">
                <label for="input-g_description" class="col-sm-2 control-label">说明</label>
                <div class="col-md-6 col-sm-10">
                    <textarea class="form-control" id="input-g_description"  name="g_description" placeholder="请填写说明"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label for="input-g_description" class="col-sm-2 control-label"></label>
                <div class="col-md-6 col-sm-10">
                    下发数量越多，所需的时间越长。未完成下发时请勿关闭页面
                </div>
            </div>
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="submit" class="btn btn-primary js-ajax-submit">下发</button>
				</div>
			</div>
		</form>
	</div>
	<script src="__STATIC__/js/admin.js"></script>
<script type="application/javascript">
    function doSelectCategory() {
        var selectedCategoriesId = $('#js-categories-id-input').val();
        openIframeLayer("{:url('gift/stars')}?ids=" + selectedCategoriesId, '请选择明星', {
            area: ['800px', '500px'],
            btn: ['确定', '取消'],
            yes: function (index, layero) {
                //do something

                var iframeWin          = window[layero.find('iframe')[0]['name']];
                var selectedCategories = iframeWin.confirm();
                if (selectedCategories.selectedCategoriesId.length == 0) {
                    layer.msg('请选择用户');
                    return;
                }
                $('#js-categories-id-input').val(selectedCategories.selectedCategoriesId.join(','));
                $('#js-categories-name-input').val(selectedCategories.selectedCategoriesName.join(' '));
                //console.log(layer.getFrameIndex(index));
                layer.close(index); //如果设定了yes回调，需进行手工关闭
            }
        });
    }
</script>
</body>
</html>